#
# Copyright Laureano Arcanio 2008
# Released under the MIT License
# laureano.arcanio@gmail.com
#

#__all__ = ['metadata', 'Page', 'Tags', 'Attrs', ]

from unittest import TestCase
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker

from tw.lymon import template
from lymon.pages import save_document, build_document
from lymon.model import *

# SqlLite
engine = create_engine('sqlite://')

#engine = create_engine('postgres://laureano:adolphito@localhost/lymon')

Session = sessionmaker(bind=engine)
metadata.create_all(engine)
session = Session()

class PageRender_Test(TestCase):
	"""
	Adds a page with the template, then loads it and rebuild the document
	The test is to Render from the Data Base and compare with Original one
	"""
	def runTest(self):

		save_document(document=template, name='Page2', session=session)
		doc = build_document(name='Page2', session=session)
		from_DB = doc(render=True)
		from_Doc = template(render=True)
			
		self.assertEqual(from_DB, from_Doc)

